package com.eleven.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.eleven.dao.NewsMapper;
import com.eleven.pojo.News;
import com.eleven.pojo.NewsExample;
import com.eleven.service.NewsService;

@Service
public class NewsServiceImpl implements NewsService {
	@Autowired
	NewsMapper newsMapper;

	public NewsMapper getNewsMapper() {
		return newsMapper;
	}

	public void setNewsMapper(NewsMapper newsMapper) {
		this.newsMapper = newsMapper;
	}

	/**
	 * 查看资讯详情By newsId
	 */
	public List<News> getAllNewsByNewsId(Integer newsId) {
		NewsExample newsExample=new NewsExample();
		newsExample.createCriteria().andNewsIdEqualTo(newsId);
		return newsMapper.selectByExample(newsExample);
	}
	
	/**
	 * 查看资讯详情By newsUsId
	 */
	public List<News> getAllNewsByNewsUserId(Integer newsUsId) {
		NewsExample newsExample=new NewsExample();
		newsExample.createCriteria().andNewsIdEqualTo(newsUsId);
		return newsMapper.selectByExample(newsExample);
	}
	
	/**
	 * 新增资讯
	 */
	public int insertNews(News news) {
		// TODO Auto-generated method stub
		return 0;
	}
	
	/**
	 * 修改资讯
	 */
	public int updateNews(Integer newsId) {
		return 0;
	/*	NewsExample newsExample=new NewsExample();
		newsExample.createCriteria().andNewsIdEqualTo(newsId);
		return newsMapper.updateByExample(record, newsExample);*/
	}
	
	/**
	 * 删除资讯
	 */
	public int deleteNews(Integer newsId) {
		NewsExample newsExample=new NewsExample();
		newsExample.createCriteria().andNewsIdEqualTo(newsId);
		return newsMapper.deleteByExample(newsExample);
	}

	/**
	 * 查看全部资讯
	 */
	public List<News> getAllNews() {
		// TODO Auto-generated method stub
		return newsMapper.selectByExample(null);
	}

}
